﻿#ifndef INSTRUCTIONTURNTABLECLOSECIRCUIT
#define INSTRUCTIONTURNTABLECLOSECIRCUIT

#include "ScriptInstruction.h"

class InstructionTurnTableCloseCircuit :public ScriptInstruction
{
  Q_OBJECT
private:
  ScriptRunner* scriptRunner = Q_NULLPTR;
  TurnTableCodec* turnTableCodec = Q_NULLPTR;
  TurnTableRunningStateManager* turnTableRunningStateManager = Q_NULLPTR;
public:
  InstructionTurnTableCloseCircuit()
  {
    scriptRunner = ScriptInstruction::getScriptRunner();
    turnTableCodec = ScriptInstruction::getTurnTableCodec();
    turnTableRunningStateManager = ScriptInstruction::getTurnTableRunningStateManager();
    instructionFlag = Instruction_TurnTable_CloseCircuit;
  }
  ~InstructionTurnTableCloseCircuit()
  {}
public:
  void run()override
  {
    turnTableCodec->sendInstruction(TurnTableCodec::TurnTable_CloseCircuit,0,0,0);
    StateChecker<TurnTableCodec::TurnTableCircuitState, TurnTableRunningStateManager>::next_ifConditionReached(&TurnTableRunningStateManager::getState_turnTable_circuit, turnTableRunningStateManager, TurnTableCodec::State_CircuitClosed, scriptRunner->getInterval_turnTableOperationTimeOut(),scriptRunner);
  }
  QVector<float> getDataForSaving()override
  {
    QVector<float> savingData;
    savingData.append(instructionFlag);
    return savingData;
  }
};
#endif
